home *** CD-ROM | disk | FTP | other *** search
Text File | 1992-09-19 | 1.5 KB | 49 lines | [TEXT/MPS ] |
- # mkkeytab - builds keyword.c, which is structure of keywords and
- # their identification numbers. also builds keyword.h, which has
- # defined constants giving keyword identification numbers.
- # input is list of keywords, (alphabetic order, one pair per line)
- # in file "keywords.txt", elements of a pair are separated by one or more
- # blanks or tabs.
-
- procedure main(args)
- local df, f, input, word, atab, serial
-
- input := open("keywords.txt") | stop("unable to open \"keywords.txt\"")
- f := open("keyword.c","w") | stop("unable to open \"keyword.c\"")
- df := open("../h/keyword.h","w") | stop("unable to open \"keyword.h\"")
- kf := open("../h/kdefs.h","w") | stop("unable to open \"kdefs.h\"")
- write(df,"/*")
- write(df," * Keyword manifest constants.")
- write(df," */\n")
-
- write(kf,"/*")
- write(kf," * Keyword definitions.")
- write(kf," */\n")
-
- write(f, "#include \"../h/keyword.h\"") # put out table header
- write(f, "#include \"tsym.h\"")
- write(f, "")
- write(f, "/*")
- write(f, " * Keyword table.")
- write(f, " */")
- write(f, "")
- write(f, "struct keyent keytab[] = {")
-
- serial := 0
- while word := read(input) do {
- if not any(&lcase,word) then next
- serial +:= 1
- if *word < 6 then atab := "\t\t" else atab := "\t"
- write(df, "#define K_",ucase(word),atab,right(serial,2))
- write(kf, "KDef(",word,")")
- write(f," \"",word,"\",\tK_",ucase(word),",")
- }
- write(f," \"\",\t\t-1")
- write(f, " };")
-
- end
-
- procedure ucase(name)
- return map(name,&lcase,&ucase)
- end
-